package com.irc.server;


import java.util.List;
import java.util.Vector;

/*
 * The IRC Server
 * @author agd
 */
public class IRCServer extends Thread {
	
	public static final int DEFAULT_PORT = 6667;
	
	private int port;
	private List<IRCUser> users;
	private List<IRCChannel> channels;
	private IRCUserListener userListener;
	
	public IRCServer(){
		users = new Vector<IRCUser>();
		channels = new Vector<IRCChannel>();
		
		userListener = new IRCUserListener(this);
	}
	
	
	/*
	 * Overrides Thread's default 'start()' to 
	 * start the user listener listening.
	 */
	@Override
	public void start(){
		userListener.start();
		
		super.start();
	}
	
	/*
	 * @return The port the server listens on
	 */
	public int getPort(){
		return this.port;
	}
	
	/*
	 * Add an IRC channel
	 */
	public void addChannel(IRCChannel c){
		channels.add(c);
	}
	
	/*
	 * Add a user
	 */
	public void addUser(IRCUser user){
		users.add(user);
	}
	
}